<%@ page contentType="text/html;charset=UTF-8" language="java" %>
<html>
<head>
    <title>发起工单</title>
    <link href="${pageContext.request.contextPath}/static/bootstrap/3.3.4/css/bootstrap.min.css" rel="stylesheet">
    <link href="${pageContext.request.contextPath}/static/css/fonts.css" rel="stylesheet">
    <link href="${pageContext.request.contextPath}/static/css/style2.css" rel="stylesheet">
    <style>
        button {
            width: 150px;
            height: auto;
        }

        #failBtn {
            float: right;
        }
    </style>
</head>
<body>
<main class="ftdms-layout-content">
    <div class="container-fluid" style="margin-bottom:90px;padding: 0px">
        <div class="row" style="margin-top:15px;">
            <div class="col-lg-12">
                <div class="card">
                    <div class="tab-content">
                        <div class="tab-pane active">
                            <div class="form-group">
                                <label for="nickName">姓名</label>
                                <input class="form-control" type="text" id="nickName" name="nickName"
                                       value="${checkUser.nickName}" readonly>
                                <input type="hidden" name="userId" value="1">
                            </div>
                            <div class="form-group">
                                <label for="password">密码</label>
                                <input class="form-control" type="text" id="password" name="password"
                                       value="${checkUser.password}" readonly>
                                <input type="hidden" name="userId" value="1">
                            </div>
                            <div class="form-group">
                                <label for="sex">性别</label>
                                <input class="form-control" type="text" id="sex" name="sex"
                                       value="${checkUser.sex}" readonly>
                                <input type="hidden" name="userId" value="1">
                            </div>
                            <div class="form-group">
                                <label for="phone">手机</label>
                                <input class="form-control" type="text" id="phone" name="phone"
                                       value="${checkUser.phone}" readonly>
                                <input type="hidden" name="userId" value="1">
                            </div>
                            <div class="form-group">
                                <button id="passBtn" type="button" class="back btn btn-primary m-r-5" value="1"
                                        onclick="javascript:;">通过审核
                                </button>
                                <button id="failBtn" type="button" class="back btn btn-primary m-r-5" value="0"
                                        onclick="javascript:;">审核失败
                                </button>
                            </div>
                        </div>
                    </div>
                </div>
            </div>
        </div>
    </div>
</main>
</body>
<script src="${pageContext.request.contextPath}/static/js/jquery3.4.1.js"></script>
<script src="${pageContext.request.contextPath}/static/layer/layer.js"></script>
<script>
    let id = ${checkUser.id};
    let nickName = $("#nickName").val();

    $("#passBtn").click(function () {
        layer.confirm('是否通过' + nickName + '的注册?', {icon: 3, title: '提示'}, function (index) {
            $.ajax({
                url: "${pageContext.request.contextPath}/user/updateUser.handler",
                data: {
                    id: id,
                    state: 1
                },
                success: function (data) {
                    if (data.state) {
                        layer.msg('修改成功!', {icon: 1,time:500}, function () {
                            let index = parent.layer.getFrameIndex(window.name);
                            parent.layui.table.reload('checkUser-form');
                            parent.layer.close(index);
                        });
                    } else {
                        layer.msg('修改失败，请重新操作！！！', {icon: 2});
                        location.reload();
                    }
                }
            });
        });
    });
    $("#failBtn").click(function () {
        layer.confirm('是否禁止' + nickName + '的注册?', {icon: 3, title: '提示'}, function (index) {
            $.ajax({
                url: "${pageContext.request.contextPath}/user/updateUser.handler",
                data: {
                    id: id,
                    state: 0
                },
                success: function (data) {
                    if (data.state) {
                        layer.msg('修改成功!', {icon: 1,time:500}, function () {
                            let index = parent.layer.getFrameIndex(window.name);
                            parent.layui.table.reload('checkUser-form');
                            parent.layer.close(index);
                        });
                    } else {
                        layer.msg('修改失败，请重新操作！！！', {icon: 2});
                        location.reload();
                    }
                }
            });
        });
    });
</script>
</html>

